/*****************************************************************************************
 * FILE NAME: srv_event                      COPYRIGHT (c) cos 2024
 * REVISION:  1.0.0                                     All Rights Reserved
 * DESCRIPTION:
 * =======================================================================================
 * UPDATE HISTORY：
 * REV      AUTHOR      DATE
 * v1.0.0   Tuxin       2024.10.14
 * DESCRIPTION OF CHANGE:
 ****************************************************************************************/
#ifndef __SVR_EVENT_H
#define __SVR_EVENT_H

//----------------------------------------------------------------------------------------
// @Project Includes
#include "typedefs.h"

//----------------------------------------------------------------------------------------
// @Global Macro Define in the module
#define EVENT_PROTOCOL_HEAD1 		(0x5A)   
#define EVENT_PROTOCOL_HEAD2		(0xA5) 

#define EVENT_SAVE_BUF_SIZE     (128)
#define EVENT_SAVE_TIMEOUT		  (5)/*超时时间3秒*/

#define EVENT_SAVE_START_ADDR		(EVENT_SAVE_ADDR)/*存储关键事件信息地址*/
#define EVENT_SAVE_TOTAL_SIZE		(EVENT_SAVE_SIZE)/*存储关键事件信息总长度*/
#define EVENT_SAVE_UNIT_SIZE		(EVENT_SAVE_BUF_SIZE)/*一个存储单元长度*/
#define EVENT_SAVE_SECTOR_SIZE	(FLASH_MAIN_SECTOR_SIZE)

//----------------------------------------------------------------------------------------
// @Global Type defines in the module
typedef enum en_event_type
{
    EVENT_TYPE_IDLE 	= 0,
    EVENT_TYPE_ALARM 	= 1,
    EVENT_TYPE_CMD 		= 2,
    EVENT_TYPE_SLEEP 	= 3,
    EVENT_TYPE_WAKEUP 	= 4,
    EVENT_TYPE_POWER 	= 5,
    EVENT_TYPE_NULL	
}en_event_type_t;
	
typedef struct stc_event
{
    uint32_t u32addrStart;/*检索起始地址*/
    uint16_t u16index;/*数据条数*/		
    uint8_t u8timeout;/*检索时间*/	
}stc_event_t;

//----------------------------------------------------------------------------------------
// @Export global Variables declare in the module
extern stc_event_t g_stcEvent;

//----------------------------------------------------------------------------------------
// @Export declaration of functions in the module
void srv_event_delete(void);
void srv_event_init(void);
void srv_event_save(en_event_type_t event , uint8_t cmd);
void srv_event_indexSearch(void);
void srv_event_timeout(void);

#endif

// =======================================================================================
// End of file.
// =======================================================================================
